<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    /*js---弱类型*/

    /*1.变更类型*/
    /*var num ;
    alert(num);
    num=1;
    alert(typeof num);
    num='str'
    alert(typeof num);*/


    /*2.回调和高阶函数*/

    /*  var arr =[1,3,5,9];

      var arr2=[];*/
    /* for (var i=0;i<arr.length;i++){
         arr2.push(arr[i]*arr[i]);
     }
     console.log(arr2);*/

    //1*1.3*3
    /*  arr2= arr.map(function (item) {
           return item*item;
       })
       console.log(arr2);*/

    /*stock  product */
    var stocks = [{
        stock_id: 1,
        product_id: 1,
        product_name: '商品1',
        model: 'N67',
        quantity: 100
    }, {
        stock_id: 1,
        product_id: 1,
        product_name: '商品1',
        model: 'N67',
        quantity: 100
    }]

    /*java---接口、流操作*/
   stocks= stocks.map(function (row) {
        return {
            stock_id: row.stock_id,
            product: {
                product_id: row.product_id,
                product_name: row.product_name,
                model: row.model
            }, quantity: row.quantity
        }
    })

console.log(stocks);
</script>
</html>